#coding:utf8
import json
from django.db import models


class User(models.Model):
    userId = models.UUIDField(primary_key=True,db_column='userId')
    loginName = models.CharField(max_length=30,unique=True)
    passWord = models.CharField(max_length=30,default=0)
    name = models.CharField(max_length=30)
    email = models.EmailField(unique=True)
    createTime = models.DateTimeField(auto_now=True)
    updateTime = models.DateTimeField(auto_now_add=True)
    lastLoginTime = models.DateTimeField()

    class Meta:
        app_label = 'ETP'
        db_table = 'User'
        verbose_name = '用户表'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name


class UserEncoder(json.JSONEncoder):
    def default(self,obj):
        if isinstance(obj,User):
            return obj.objects
        return json.JSONEncoder.default(self,obj)